home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Resources / Audio, Video & Photo / Songbird 0.7.0 / Songbird_0.7.0_windows-i686-msvc8.exe / components / sbDownloadDeviceServicePaneModule.js < prev    next >
Text File  |  2008-08-06  |  7KB  |  205 lines

  1. /*
  2. //
  3. // BEGIN SONGBIRD GPL
  4. //
  5. // This file is part of the Songbird web player.
  6. //
  7. // Copyright(c) 2005-2008 POTI, Inc.
  8. // http://songbirdnest.com
  9. //
  10. // This file may be licensed under the terms of of the
  11. // GNU General Public License Version 2 (the "GPL").
  12. //
  13. // Software distributed under the License is distributed
  14. // on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
  15. // express or implied. See the GPL for the specific language
  16. // governing rights and limitations.
  17. //
  18. // You should have received a copy of the GPL along with this
  19. // program. If not, go to http://www.gnu.org/licenses/gpl.html
  20. // or write to the Free Software Foundation, Inc.,
  21. // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  22. //
  23. // END SONGBIRD GPL
  24. //
  25. */
  26.  
  27. Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
  28. Components.utils.import("resource://app/jsmodules/sbProperties.jsm");
  29.  
  30. const Ci = Components.interfaces;
  31. const Cc = Components.classes;
  32. const Cr = Components.results;
  33.  
  34. function sbDownloadDeviceServicePaneModule()
  35. {
  36.   this._servicePaneNode = null;
  37.   this._downloadDevice = null;
  38.   this._currentState = Ci.sbIDeviceBase.STATE_IDLE;
  39. }
  40.  
  41. sbDownloadDeviceServicePaneModule.prototype =
  42. {
  43.   classDescription: "Songbird Download Device Service Pane Module",
  44.   classID:          Components.ID("{ee93796b-090e-4703-982a-1d27bea552c3}"),
  45.   contractID:       "@songbirdnest.com/Songbird/DownloadDeviceServicePaneModule;1",
  46.   QueryInterface:   XPCOMUtils.generateQI([Ci.sbIServicePaneModule,
  47.                                            Ci.sbIDeviceBaseCallback])
  48. }
  49.  
  50. // sbIServicePaneModule
  51. sbDownloadDeviceServicePaneModule.prototype.servicePaneInit =
  52. function sbDownloadDeviceServicePaneModule_servicePaneInit(aServicePaneModule)
  53. {
  54.   var devMgr = Cc["@songbirdnest.com/Songbird/DeviceManager;1"]
  55.                  .getService(Ci.sbIDeviceManager);
  56.   var downloadCat = "Songbird Download Device";
  57.   if (devMgr.hasDeviceForCategory(downloadCat)) {
  58.     this._downloadDevice = devMgr.getDeviceByCategory(downloadCat)
  59.                                  .QueryInterface(Ci.sbIDownloadDevice);
  60.   }
  61.   this._downloadDevice.addCallback(this);
  62.   this._currentState = this._downloadDevice.getDeviceState("download");
  63.   this._updateState();
  64. }
  65.  
  66. sbDownloadDeviceServicePaneModule.prototype.fillContextMenu =
  67. function sbDownloadDeviceServicePaneModule_fillContextMenu(aNode,
  68.                                                            aContextMenu,
  69.                                                            aParentWindow)
  70. {
  71. }
  72.  
  73. sbDownloadDeviceServicePaneModule.prototype.fillNewItemMenu =
  74. function sbDownloadDeviceServicePaneModule_fillNewItemMenu(aNode,
  75.                                                            aContextMenu,
  76.                                                            aParentWindow)
  77. {
  78. }
  79.  
  80. sbDownloadDeviceServicePaneModule.prototype.onSelectionChanged =
  81. function sbDownloadDeviceServicePaneModule_onSelectionChanged(aNode,
  82.                                                               aContainer,
  83.                                                               aParentWindow)
  84. {
  85. }
  86.  
  87. sbDownloadDeviceServicePaneModule.prototype.canDrop =
  88. function sbDownloadDeviceServicePaneModule_canDrop(aNode,
  89.                                                    aDragSession,
  90.                                                    aOrientation,
  91.                                                    aWindow)
  92. {
  93. }
  94.  
  95. sbDownloadDeviceServicePaneModule.prototype.onDrop =
  96. function sbDownloadDeviceServicePaneModule_onDrop(aNode,
  97.                                                   aDragSession,
  98.                                                   aOrientation,
  99.                                                   aWindow)
  100. {
  101. }
  102.  
  103. sbDownloadDeviceServicePaneModule.prototype.onDragGesture =
  104. function sbDownloadDeviceServicePaneModule_onDragGesture(aNode,
  105.                                                          aTransferable)
  106. {
  107. }
  108.  
  109. sbDownloadDeviceServicePaneModule.prototype.onRename =
  110. function sbDownloadDeviceServicePaneModule_onRename(aNode,
  111.                                                     aNewName)
  112. {
  113. }
  114.  
  115. sbDownloadDeviceServicePaneModule.prototype.__defineGetter__("stringBundle",
  116. function sbDownloadDeviceServicePaneModule_get_stringBundle()
  117. {
  118. });
  119.  
  120. sbDownloadDeviceServicePaneModule.prototype.shutdown =
  121. function sbDownloadDeviceServicePaneModule_shutdown()
  122. {
  123.   if (this._downloadDevice) {
  124.     this._downloadDevice.removeCallback(this);
  125.   }
  126. }
  127.  
  128. // sbIDeviceBaseCallback
  129. sbDownloadDeviceServicePaneModule.prototype.onDeviceConnect =
  130. function sbDownloadDeviceServicePaneModule_onDeviceConnect(aDeviceIdentifier)
  131. {
  132. }
  133.  
  134. sbDownloadDeviceServicePaneModule.prototype.onDeviceDisconnect =
  135. function sbDownloadDeviceServicePaneModule_onDeviceDisconnect(aDeviceIdentifier)
  136. {
  137. }
  138.  
  139. sbDownloadDeviceServicePaneModule.prototype.onTransferStart =
  140. function sbDownloadDeviceServicePaneModule_onTransferStart(aSourceURL,
  141.                                                            aDestinationURL)
  142. {
  143. }
  144.  
  145. sbDownloadDeviceServicePaneModule.prototype.onTransferComplete =
  146. function sbDownloadDeviceServicePaneModule_onTransferComplete(aSourceURL,
  147.                                                               aDestinationURL)
  148. {
  149. }
  150.  
  151. sbDownloadDeviceServicePaneModule.prototype.onStateChanged =
  152. function sbDownloadDeviceServicePaneModule_onStateChanged(aDeviceIdentifier,
  153.                                                           aState)
  154. {
  155.   this._currentState = aState;
  156.   this._updateState();
  157. }
  158.  
  159. sbDownloadDeviceServicePaneModule.prototype.__defineGetter__("_node",
  160. function sbDownloadDeviceServicePaneModule_get_node()
  161. {
  162.   if (!this._servicePaneNode) {
  163.     var lsps = Cc["@songbirdnest.com/servicepane/library;1"]
  164.                  .getService(Ci.sbILibraryServicePaneService);
  165.     this._servicePaneNode =
  166.       lsps.getNodeForLibraryResource(this._downloadDevice.downloadMediaList);
  167.   }
  168.   return this._servicePaneNode;
  169. });
  170.  
  171. sbDownloadDeviceServicePaneModule.prototype._updateState =
  172. function sbDownloadDeviceServicePaneModule_onStateChanged()
  173. {
  174.   if (this._node) {
  175.     var a = this._node.properties.split(" ");
  176.  
  177.     // Remove the "progress" property from the array, if any
  178.     a = a.filter(function(property) {
  179.       return property != "downloading";
  180.     });
  181.  
  182.     if (this._currentState == Ci.sbIDeviceBase.STATE_DOWNLOADING) {
  183.       a.push("downloading");
  184.     }
  185.  
  186.     this._node.properties = a.join(" ");
  187.   }
  188. }
  189.  
  190. function NSGetModule(compMgr, fileSpec) {
  191.   var module = XPCOMUtils.generateModule(
  192.     [sbDownloadDeviceServicePaneModule],
  193.       function(aCompMgr, aFileSpec, aLocation) {
  194.       XPCOMUtils.categoryManager.addCategoryEntry(
  195.         "service-pane",
  196.         "z-download-device-service-pane-module",
  197.         sbDownloadDeviceServicePaneModule.prototype.contractID,
  198.         true,
  199.         true);
  200.       }
  201.     );
  202.   return module;
  203. }
  204.  
  205.